package com.zxm.web.controller.message;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author silence.Z
 * @Date 2022/8/29 11:45
 * @PackageName:com.zxm.web.controller.message
 * @ClassName: IframeController
 * @Description: TODO
 * @Version 1.0
 */
@Controller
@RequestMapping("/iframe")
public class IframeController {
	@GetMapping(path = "message")
	public void message(HttpServletResponse response) throws IOException, InterruptedException {
		while (true) {
			response.setHeader("Pragma", "no-cache");
			response.setDateHeader("Expires", 0);
			response.setHeader("Cache-Control", "no-cache,no-store");
			response.setStatus(HttpServletResponse.SC_OK);
			response.getWriter().print(" <script type=\"text/javascript\">\n" +
					"parent.document.getElementById('clock').innerHTML = \"" + 1 + "\";" +
					"parent.document.getElementById('count').innerHTML = \"" + 2 + "\";" +
					"</script>");
		}
	}
}

